import { Vec3, SpriteFrame } from 'cc';

export const plantNames: string[] = [
  'cherrybomb',
  'chomper',
  'gatlingpea',
  'peashooter',
  'repeater',
  'sunflower',
  'wallnut',
];

type PlantNames = (typeof plantNames)[number];

export const zombieNames: string[] = ['normal'];

export type ZombieNames = (typeof zombieNames)[number];

export type PlantAction = 'idle' | 'attack' | 'digest';

export type ZombieAction =
  | 'idle'
  | 'attack'
  | 'run'
  | 'dying'
  | 'dieboom'
  | 'die';

export class CommonData {
  private static _instance: CommonData;

  public curLevel: number = 1; // 当前关卡数据

  public currentMode: 'classic' | 'adventure' = 'classic';

  public zombieWaves: any[] = []; // 僵尸波数配置

  public gridCenters: Vec3[][] = [];

  public plantFramesMap: Map<PlantNames, Map<PlantNames, SpriteFrame[]>> =
    new Map();

  public zombieFramesMap: Map<ZombieNames, Map<ZombieAction, SpriteFrame[] | SpriteFrame[][]>> =
    new Map();

  public sunFrames: SpriteFrame[] = [];

  private constructor() {}

  public static get instance(): CommonData {
    if (!this._instance) {
      this._instance = new CommonData();
    }
    return this._instance;
  }
}
